<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Lap_peserta extends CI_Controller {
	
	function __construct(){
		parent::__construct();
		$this->load->model('mdl_lap_peserta');
		$this->load->library('Excel_generator');
		//$this->output->enable_profiler(TRUE);
	}
	
	function index(){
		$this->load->view('lap_peserta');
	}
	
	
	function grid(){
		$data = $this->mdl_lap_peserta->getdata();
		echo $this->mdl_lap_peserta->togrid($data['row_data'], $data['row_count']);
	}
	
	function laporan_pdf($PMBPeriodID){
		 $this->load->library('HTML2PDF');
		 $html2pdf = new HTML2PDF('L', 'A4', 'fr');
		 $html2pdf->setDefaultFont('Arial');
		
		//filter
		#get filter
		$fil['PMBPeriodID'] = $PMBPeriodID;
		
		 //$data['nama'] = 'indriyanto';
		 $data['namaUniv'] = 'UNIVERSITAS OTTOW GEISSLER';
		 $data['alamatUniv'] = 'Jln. Perkutut Kotaraja, Telp.(0967)581562';
		 $data['kotaUniv'] = 'Jayapura, Papua';
		 // ambil data dari tabel
		$data['data_pdf'] = $this->mdl_lap_peserta->get_pdf($fil);
		
		
		/* if (count($da['row'])==0){
			echo "Data Tidak Tersedia";
			return;
		} */
		
		
		 $konten = $this->load->view('peserta_laporan',$data,true);
		
         $html2pdf->writeHTML($konten, false);
        
		 $html2pdf->Output('peserta_pmb.pdf');
	}
	
	function laporan_excel() {			
		$query = $this->db->get('pmb_pendaftaran');
			$this->excel_generator->set_query($query);
			$this->excel_generator->set_header(array('ID Pendaftaran', 'Periode PMB', 'No Pendaftaran', 'Nama', 'Tempat Lahir', 'Tgl Lahir', 'Kota', ' Alamat', 'Asal Sekolah', 'No Telp', 'Email', 'Fakultas 1', 'Prodi 1', 'Fakultas 2', 'Prodi 2', 'Status'));
			$this->excel_generator->set_column(array('id_pendaftaran', 'PMBPeriodID', 'no_pendaftaran', 'nama', 'tempat_lahir', 'tgl_lahir', 'kota', 'alamat','asal_sekolah', 'no_telp', 'email', 'fakultas1', 'prodi1', 'fakultas2', 'prodi2', 'status'));
			$this->excel_generator->set_width(array(10, 10, 10, 25, 15, 15, 10, 25, 20, 10, 10, 10, 10, 10, 10, 10, 10));
			$this->excel_generator->exportTo2007('Peserta PMB');
	}
}